package com.gdth.bank.activity;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.gdth.bank.R;
import com.gdth.bank.presenter.DzCpKhXxPosPresenter;
import com.gdth.bank.view.DzCpKhXxPosView;
import com.gdth.bank.widget.BankDrawDownListTextView;
import com.gdth.bank.widget.BankEditText;
import com.gdth.core.annotation.view.ViewInject;
import com.gdth.core.widget.BaseActivity;
import com.gdth.database.bean.DzCpkhXxDjPos;
import com.gdth.widget.dialog.BaseToast;

public class DzCpPosYingXiaoXiXiWanShanActivity  extends BaseActivity implements DzCpKhXxPosView{
	@ViewInject(id=R.id.header_label_title) TextView txt_header_title;
	@ViewInject(id=R.id.header_btn_left, click="finishClick") TextView txt_header_left;
	@ViewInject(id=R.id.header_btn_right, click="searchClick") TextView txt_header_right;
    @ViewInject(id=R.id.dzcpkhxx_linear_nav) LinearLayout linear_nav;
	@ViewInject(id=R.id.dzcpkh_xm) BankEditText txt_khxm;
	@ViewInject(id=R.id.dzcpkh_sfzhm) BankEditText txt_khsfzhm;
	@ViewInject(id=R.id.dzcpkh_sjhm) BankEditText txt_khsjhm;
	@ViewInject(id=R.id.dzcpkh_zdh) BankEditText dzcpkh_zdh;
	@ViewInject(id=R.id.dzcpkh_shh) BankEditText dzcpkh_shh;
	@ViewInject(id=R.id.dzcpkh_khckzh) BankEditText dzcpkh_khckzh;
	@ViewInject(id=R.id.dzcpkh_sbzt) BankEditText dzcpkh_sbzt;
	@ViewInject(id=R.id.dzcpkh_pos_jg) BankDrawDownListTextView drawDownList_etc_khjg;
	@ViewInject(id=R.id.dzcpkh_zjlx) BankDrawDownListTextView drawDownList_etc_khzjlx;
	@ViewInject(id=R.id.noScrollgridviewpos, itemClick="onItemClick") GridView gridview_phone;
	private Button searchButton;
	private TextView mTextView;
	/** 提示框 */
    ProgressDialog mProgressDialog;
    DzCpKhXxPosPresenter mDzCpKhXxPosPresenter;
	
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dzcp_pos);
		init();
		initializeView();
		
	}
	public void initializeView(){
		txt_header_title.setText(getResources().getString(R.string.param200));
		txt_khxm.setLabel(R.string.dzcpxxdj_kh_xm);
		txt_khxm.setImage(null);
		txt_khxm.mEditText.setEnabled(false);
		txt_khsfzhm.setLabel(R.string.dzcpxxdj_kh_sfzhm);
		txt_khsfzhm.setImage(null);
		txt_khsfzhm.mEditText.setEnabled(false);
		txt_khsjhm.setLabel(R.string.dzcpxxdj_kh_sjhm);
		txt_khsjhm.setImage(null);
		txt_khsjhm.mEditText.setEnabled(false);
		dzcpkh_zdh.setLabel(R.string.dzcpxxdj_kh_zdh);
		dzcpkh_zdh.setImage(null);
		dzcpkh_zdh.setHint(R.string.dzcpxxdj_kh_zdh_hint);
		dzcpkh_shh.setLabel(R.string.dzcpxxdj_kh_shh);
		dzcpkh_shh.setImage(null);
		dzcpkh_shh.setHint(R.string.dzcpxxdj_kh_shh_hint);
		dzcpkh_khckzh.setLabel(R.string.dzcpxxdj_kh_ckzh);
		dzcpkh_khckzh.setImage(null);
		dzcpkh_khckzh.mEditText.setEnabled(false);
		drawDownList_etc_khjg.setLabel(R.string.dzcpxxdj_kh_jg);
		drawDownList_etc_khzjlx.setLabel(R.string.dzcpxxdj_kh_zjlx);
		dzcpkh_sbzt.setVisibility(View.GONE);
		gridview_phone.setVisibility(View.GONE);
		txt_khxm.setVisibility(View.GONE);
		txt_khsfzhm.setVisibility(View.GONE);
		txt_khsjhm.setVisibility(View.GONE);
		dzcpkh_khckzh.setVisibility(View.GONE);
		drawDownList_etc_khjg.setVisibility(View.GONE);
		drawDownList_etc_khzjlx.setVisibility(View.GONE);
		
		txt_header_right.setText("查询");
		txt_header_right.setBackgroundDrawable(null);
//		searchButton.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				searchClick();
//			}
//		});
		
		
	}
	public void init() {
		mProgressDialog = new ProgressDialog(this);
		searchButton =(Button) findViewById(R.id.searchButton);
		searchButton.setVisibility(View.GONE);
		mTextView = (TextView) findViewById(R.id.txt_kh_tx);
		mTextView.setVisibility(View.VISIBLE);
		mDzCpKhXxPosPresenter = new DzCpKhXxPosPresenter(this);
		
	}
	public void searchClick(View arg0){
	  String zdh= dzcpkh_zdh.getValue();
	  String shh = dzcpkh_shh.getValue();
	  if(!zdh.equals("") && !shh.equals("")){
		  JSONObject json = new JSONObject();
		  
		  try {
			json.put("shh", shh);
			json.put("zdh", zdh);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  mDzCpKhXxPosPresenter.searchDzcpPos(json.toString());
	  }else if(zdh.equals("")){
		  Toast.makeText(this, getResources().getString(R.string.param201), Toast.LENGTH_SHORT).show();
	  }else if(shh.equals("")){
		  Toast.makeText(this, getResources().getString(R.string.param202), Toast.LENGTH_SHORT).show();
	  }
 
 }
	@Override
	public void showProgressDialog(String msg) {
		// TODO Auto-generated method stub
		mProgressDialog.setMessage(msg);
		mProgressDialog.show();
		
	}
	@Override
	public void hideProgressDialog() {
		// TODO Auto-generated method stub
		mProgressDialog.hide();
	}
	@Override
	public void showMessage(String msg) {
		// TODO Auto-generated method stub
		BaseToast.getInstance().ShowSystemToast(this, msg);
	}
	@Override
	public void updateViewpos(int type, Object Obj) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void success() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void scsuccess() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void updateListpos(List<DzCpkhXxDjPos> mList) {
		// TODO Auto-generated method stub
		String appuuid =mList.get(0).getAppUuid();
		String zdh= dzcpkh_zdh.getValue();
		String shh = dzcpkh_shh.getValue();
		if(!appuuid.equals("")){
			Intent intent = new Intent();
			intent.setClass(DzCpPosYingXiaoXiXiWanShanActivity.this, DzCpKhXxPosBuLuXxActivity.class);
			intent.putExtra("appuuid", appuuid);
			intent.putExtra("zdh", zdh);
			intent.putExtra("shh", shh);
			startActivity(intent);
		}
	}
	@Override
	public void jyZhj(String arg0) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void refreshData(List<DzCpkhXxDjPos> mList) {
		// TODO Auto-generated method stub
		
	}
		
	
	
}
